package com.yushixin.order.controller;

import com.yushixin.common.result.R;
import com.yushixin.order.model.Order;
import com.yushixin.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/orders")
public class OrderController {
    
    @Autowired
    private IOrderService orderService;
    
    @GetMapping
    public R<List<Order>> findAll() {
        return R.success(orderService.findAll());
    }
    
    @PostMapping
    public R<Void> createOrder(Order order) {
        orderService.createOrder(order);
        return R.success();
    }
}